// 修改密码
<template>
    <div>
        <GoBack></GoBack>
        <div class="modifyBox">
            <p class="adselfBox">修改密码</p>
            <div class="modifyCont">
                <p class="userName">会员名<span>{{$store.state.userInfo.user_name}}</span></p>
                <div class="selcetBox flex flex-align-center">
                 <p>原密码</p>
                 <input type="text" placeholder="请输入原来密码" v-model.trim='password'>
                </div>
                <div class="selcetBox flex flex-align-center">
                 <p>新密码</p>
                 <input type="text" placeholder="请输入新密码"  v-model.trim='new_password'>
                </div>
                <div class="selcetBox flex flex-align-center">
                 <p class="queren">确认密码</p>
                 <input type="text" placeholder="请确认新密码"  v-model.trim='new_repeat_password'>
                </div>
                <div class="qrBtn flex flex-align-center flex-pack-center" @click="onModifyPwd"><p>确认修改</p></div>
            </div>
        </div>
    </div>
</template>
<script>
import GoBack from '../goback'
import https from '@/public/https'
export default {
    components: {
        GoBack
    },
    data () {
        return {
          password:'',
          new_password:'',
          new_repeat_password:'',
        }
    },
    methods: {
        onModifyPwd(){ //修改密码
          let password = this.password;
          let new_password = this.new_password;
          let new_repeat_password  = this.new_repeat_password;
          if(new_password != '' && password != '' && new_repeat_password != ''){
              if(new_repeat_password == new_password){
                    https.post('user/postUpdatePassword',{new_password:new_password,new_repeat_password:new_repeat_password,old_password:password})
                    .then(data => {
                        if(data.status == 1){
                              this.$toast({
                                message: '修改密码成功'
                                });
                                this.password = '';
                                this.new_password = '';
                                this.new_repeat_password = '';
                        }else{
                            this.$toast({message:data.message});
                        }
                    })
              }else{
                   this.$toast({message:'新密码确认密码不一致，请重新输入'});
              }
          }
        }
    }
}
</script>
<style lang="less" scoped>
@import url(../../assets/css/usercenter/modifypwd.less);
</style>


